#!/bin/bash


# 编译环境及 mysql 依赖
yum install -y gcc gcc-c++ ncurses ncurses-devel wget

# 安装RPM包生成工具
yum install -y rpmdevtools

# 下载mysql
[ -f mysql-5.1.73.tar.gz ] || wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.73.tar.gz

# 初始化目录结构
rm -rf rpmbuild
rpmdev-setuptree

# 复制源码到 SOURCE 目录
cp mysql-5.1.73.tar.gz rpmbuild/SOURCES
cp my.cnf mysqld.server rpmbuild/SOURCES

# 编译并打包
cp mysql.spec rpmbuild/SPECS/mysql.spec
rpmbuild -bb rpmbuild/SPECS/mysql.spec
